package com.zhongkai.model3;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.codehaus.jackson.annotate.JsonBackReference;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

@Entity
@Table(name = "menus_role",    catalog = "")
public class MenusRole implements Serializable {
    private Integer number;
    private Integer id;
    private Long sigId;
    private Menus menusByNumber;

    @JsonBackReference
    @JsonIgnore
    private SetRole setRoleById;

    @Basic
    @Column(name = "number")
    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    @Basic
    @Column(name = "id")
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Id
    @GenericGenerator(name = "generator", strategy = "increment")
    @GeneratedValue(generator = "generator")
    @Column(name = "sig_id")
    public Long getSigId() {
        return sigId;
    }

    public void setSigId(Long sigId) {
        this.sigId = sigId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MenusRole menusRole = (MenusRole) o;
        return Objects.equals(number, menusRole.number) &&
                Objects.equals(id, menusRole.id) &&
                Objects.equals(sigId, menusRole.sigId);
    }

    @Override
    public int hashCode() {

        return Objects.hash(number, id, sigId);
    }


    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "number", referencedColumnName = "number",insertable = false, updatable = false )
    public Menus getMenusByNumber() {
        return menusByNumber;
    }

    public void setMenusByNumber(Menus menusByNumber) {
        this.menusByNumber = menusByNumber;
    }


    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "id", referencedColumnName = "id",insertable = false, updatable = false )
    public SetRole getSetRoleById() {
        return setRoleById;
    }

    public void setSetRoleById(SetRole setRoleById) {
        this.setRoleById = setRoleById;
    }
}
